@echo on
cd /d "%~dp0..\.."
call :GetWinXShell
call :GetFolderName "%~p0"
if exist %temp%\AppStore rd /s /q %temp%\AppStore
mkdir %temp%\AppStore
cd /d %temp%\AppStore
git clone https://gitee.com/JiaossSky_admin/AppStore.git
cd /d "%~dp0"
start "" /w %WINXSHELL%  -code "QuitWindow(nil,'AppStore')"
call :checkrobocopy
exit
goto :EOF
:GetWinXShell
if exist x64\Debug\WinXShell.exe set WINXSHELL=x64\Debug\WinXShell.exe&&goto :EOF
if exist WinXShell.exe set WINXSHELL=WinXShell.exe&&goto :EOF
if exist WinXShell_%PROCESSOR_ARCHITECTURE%.exe set WINXSHELL=WinXShell_x86.exe&&goto :EOF
set WINXSHELL=WinXShell_x64.exe
goto :EOF

:GetFolderName
if "x%~2"=="x1" set "p0=%~n1" && goto :EOF
set "p0=%~1"
set p0=%p0:~0,-1%
call :GetFolderName  "%p0%" 1
goto :EOF

:checkrobocopy
if exist %systemdrive%\windows\system32\robocopy.exe (
robocopy %temp%\AppStore\appstore\appstore "X:\Program Files\Softwarp\AppStore"
robocopy %temp%\AppStore\appstore\bin "X:\Program Files\Softwarp\bin"
robocopy %temp%\AppStore\appstore\buildAppStore.bat "X:\Program Files\Softwarp"
robocopy  %temp%\AppStore\appstore\wxsUI\UI_AppStore "X:\Program Files\WinXShell\wxsUI\UI_AppStore"
)
exit /b